package com.gitee.srurl.core.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gitee.srurl.core.domain.SusUserDomain;
import com.gitee.srurl.core.domain.SusVisitorRecordDomain;
import com.gitee.srurl.core.mapper.SusVisitorRecordMapper;
import com.gitee.srurl.core.service.ISusVisitorRecordService;
import com.gitee.srurl.core.util.PageQuery;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author zxw
 * @date 2023/4/29 17:24
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SusVisitorRecordServiceImpl extends ServiceImpl<SusVisitorRecordMapper, SusVisitorRecordDomain> implements ISusVisitorRecordService {
    @Override
    public IPage<SusVisitorRecordDomain> getList(PageQuery pageQuery, SusVisitorRecordDomain visitorRecordDomain) {

        LambdaQueryWrapper<SusVisitorRecordDomain> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StrUtil.isNotBlank(visitorRecordDomain.getShortId()), SusVisitorRecordDomain::getShortId, visitorRecordDomain.getShortId())
                .like(StrUtil.isNotBlank(visitorRecordDomain.getOriginUrl()), SusVisitorRecordDomain::getOriginUrl, visitorRecordDomain.getOriginUrl())
                .like(StrUtil.isNotBlank(visitorRecordDomain.getIp()), SusVisitorRecordDomain::getIp, visitorRecordDomain.getIp());

        return this.page(pageQuery.build(), queryWrapper);
    }
}
